package com.fighYo.edu.controller;


import com.fighYo.commonutils.R;
import com.fighYo.edu.entity.EduVideo;
import com.fighYo.edu.entity.vo.VideoVo;
import com.fighYo.edu.service.EduVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author fighYo
 * @since 2021-08-24
 */
@CrossOrigin
@RestController
@RequestMapping("/edu/video")
public class EduVideoController {

    @Autowired
    private EduVideoService eduVideoService;

    @PostMapping("saveVideo")
    public R addVideo(@RequestBody VideoVo videoVo) {
        eduVideoService.saveVideo(videoVo);
        return R.ok();
    }

    @PutMapping("updateVideo")
    public R updateVideo(@RequestBody VideoVo videoVo) {
        eduVideoService.updateVideo(videoVo);
        return R.ok();
    }

    @GetMapping("getVideo/{id}")
    public R getVideoById(@PathVariable("id") String id) {
        VideoVo videoVo = eduVideoService.getVideoById(id);

        return R.ok().data("item", videoVo);
    }

    @DeleteMapping("deleteVideo/{id}")
    public R deleteVideo(@PathVariable("id") String id) {
        eduVideoService.removeById(id);
        return R.ok();
    }
}

